<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Layout extends Controller_Template
{

	public $template = 'template/simplaAdmin'; //so precisa setar se nao for usar o padrão
	
	protected static $per_list = 1;
	
	protected static $messagesClasses = array( 
												"a" => "attention", 
												"i" => "information", 
												"s" => "success", 
												"e" => "error" 
										);
										
	/**
	* The before() method is called before your controller action.
	* In our template controller we override this method so that we can
	* set up default values. These variables are then available to our
	* controllers if they need to be modified.
	*/
	
	public function before()
	{
		parent::before();
  	    
		if ($this->auto_render)
		{
  	    	// Initialize empty values
  	    	$this->template->title   = '';
  	    	$this->template->content = '';
  			
  			$this->template->styles = array();
  			$this->template->scripts = array();
          			
		}
	}
  	
      /**
       * The after() method is called after your controller action.
       * In our template controller we override this method so that we can
       * make any last minute modifications to the template before anything
       * is rendered.
       */
	public function after()
	{	
		if ($this->auto_render)
		{
			$styles = array(
			'resources/css/adjust.css' => 'screen, projection',
			'resources/css/reset.css' => 'screen, projection',
			'resources/css/style.css' => 'screen,print',
			'resources/css/invalid.css' => 'screen',
			);
  
			$scripts = array(
			'resources/scripts/jquery-1.3.2.min.js',
			'resources/scripts/simpla.jquery.configuration.js',
			'resources/scripts/facebox.js',
			'resources/scripts/funcoes.js',
			'resources/scripts/jquery.wysiwyg.js',
			'resources/scripts/DD_belatedPNG_0.0.7a.js',
			);
		
			$this->template->styles = array_merge( $this->template->styles, $styles );
			$this->template->scripts = array_merge( $this->template->scripts, $scripts );
		}
		
		parent::after();
    }

    // By CDTI
    public function serializePost(&$obj, &$post) {
    	foreach( $post as $key => $value ){
    		try {
    			$obj->{$key} = arr::get($post, $key);
    		} catch (Exception $e) {
    			echo 'Property \''.$key.'\' not found!';
    		}
    	}
    }
    
} // End Welcome
